package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.Grade;
import com.juneng.mapper.GradeMapper;
import com.juneng.service.IGradeService;
import com.juneng.dto.GradeDto;
import com.juneng.dto.GradeQueryDto;
import com.juneng.vo.GradeVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 年级信息 服务实现类
 *
 * @author zds
 * @since 2021-08-06
 */
@Service
@AllArgsConstructor
public class GradeServiceImpl implements IGradeService {

    protected GradeMapper gradeMapper;
    @Override
    public IPage<GradeVo> page(GradeQueryDto dto) {
        IPage<GradeVo> page = Condition.getPage(dto);
        return gradeMapper.page(page,dto);
    }

    @Override
    public List<Grade> list(GradeQueryDto dto) {
        QueryWrapper<Grade> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,Grade.class));
        return gradeMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(GradeDto dto) {
        return gradeMapper.insert(BeanCopyUtils.copy(dto,Grade.class));
    }

    @Override
    public Integer updateById(GradeDto dto) {
        return gradeMapper.updateById(BeanCopyUtils.copy(dto,Grade.class));
    }

    @Override
    public Integer deleteLogic(List<Integer> toIntList) {
        return gradeMapper.deleteBatchIds(toIntList);
    }

    @Override
    public Grade getById(Integer id) {
        return gradeMapper.selectById(id);
    }
}
